package scantask.containers.operationStanzas;

import java.util.Vector;

import scantask.containers.Benchmark;

import scantask.server.domainLayer.ControllerInterface;
import scantask.server.domainLayer.Exceptions.GetUserBenchmarksException;

public class GetBenchmarksStanza extends Stanza {
	
	private String _userName; 
	
	public GetBenchmarksStanza(String userName) {
		this._userName = userName;
	}

	@Override
	public String perform(ControllerInterface controller) {
		try {
			Vector<Benchmark> benchmarks = controller.getUserBenchmarks(this._userName);
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending benchmarks to " + this._userName);
			return this.parseToXML(benchmarks);
		} catch (GetUserBenchmarksException e) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending exception to " + this._userName + " about get benchmarks request");
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning(e.getErrorDescription());
			return this.parseToXML(e);
		}
	}

}
